home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
tvdmx.exe
/
TVDMX.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-07-16
|
60KB
|
2,362 lines
{■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■}
{ }
{ tvDMX --data editing project (ver 1.5) }
{ }
{ Copyright (c) 1992 Randolph Beck }
{ P.O. Box 56-0487 }
{ Orlando, FL 32856 }
{ CIS: 72361,753 }
{ }
{■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■}
Unit tvDMX;
{$B-,D-,O+,R-,X+,V- }
interface
uses Objects, Drivers, Views, App, RSet, DmxGizma;
type
PDmxLink = ^TDmxLink;
PDmxLabels = ^TDmxLabels;
PDmxScroller = ^TDmxScroller;
PDmxRecInd = ^TDmxRecInd;
PDmxEditor = ^TDmxEditor;
TDmxLink = OBJECT (TView)
Link : PDmxScroller;
constructor Init (Bounds : TRect);
constructor Load (var S : TStream);
function GetPalette : PPalette; VIRTUAL;
procedure Store (var S : TStream);
procedure Insert (AOwner : PGroup);
end;
TDmxLabels = OBJECT (TDmxLink)
Len : integer;
Data : PCharArray;
constructor Init (DataStr : pstring; var Bounds : TRect);
constructor InitInsert (AOwner : PGroup; DataStr : pstring);
procedure HandleEvent (var Event : TEvent); VIRTUAL;
procedure Draw; VIRTUAL;
procedure DrawRuler (Upper, AtLimit : boolean);
constructor Load (var S : TStream);
procedure Store (var S : TStream);
end;
TDmxScroller = OBJECT (TScroller)
Labels : PDmxLink;
WorkingData : pointer;
DataBlockSize : longint;
CurrentRecord : integer;
CurrentField : pDMXfieldrec;
DMXfield1 : pDMXfieldrec;
LeftField : pDMXfieldrec;
TotalFields : integer;
RecordSize : integer;
Locked : boolean;
InitValid : boolean;
constructor Init (ATemplate : string; var AData; BSize : longint;
var Bounds : TRect; ALabels : PView; AHScrollBar,AVScrollBar : PScrollBar);
procedure InitStruct (var ATemplate ); VIRTUAL;
procedure InitData (var AData ); VIRTUAL;
destructor Done; VIRTUAL;
constructor Load (var S : TStream);
procedure Store (var S : TStream);
procedure LoadData (var S : TStream); VIRTUAL;
procedure LoadStruct (var S : TStream); VIRTUAL;
procedure StoreData (var S : TStream); VIRTUAL;
procedure StoreStruct (var S : TStream); VIRTUAL;
procedure DoneStruct; VIRTUAL;
procedure DoneData; VIRTUAL;
function Valid (Command : word) : boolean; VIRTUAL;
procedure ChangeBounds (var Bounds : TRect); VIRTUAL;
function GetPalette : PPalette; VIRTUAL;
procedure HandleEvent (var Event : TEvent); VIRTUAL;
procedure WrongKeypressed (var Event : TEvent); VIRTUAL;
procedure SetState (AState : word; Enable : boolean); VIRTUAL;
function DataAt (RecNum : integer) : pointer; VIRTUAL;
procedure DrawRecord (Y : integer; var DataRecord );
procedure Draw; VIRTUAL;
private
InBuffer : boolean;
DDelta,DSize : TPoint;
vwidth : integer;
end;
TDmxRecInd = OBJECT (TDmxLink)
constructor Init (Bounds : TRect; Len : integer);
constructor InitInsert (AOwner : PGroup; Len : integer);
procedure SetState (AState : word; Enable : boolean); VIRTUAL;
procedure Draw; VIRTUAL;
end;
TDmxEditor = OBJECT (TDmxScroller)
RecInd : PDmxLink;
FieldData : pointer;
RecordData : pointer;
CurPos : integer;
Vidis : boolean;
DoubleValid : boolean;
FirstKey : boolean;
RedrawRecord : boolean;
FieldAltered : boolean;
RecordAltered : boolean;
JustAltered : boolean;
DataAltered : boolean;
FieldSelected : boolean;
RecordSelected : boolean;
constructor Init (ATemplate : string; var AData; BSize : longint;
var Bounds : TRect; ALabels,ARecInd : PDmxLink;
AHScrollBar,AVScrollBar : PScrollBar);
constructor Load (var S : TStream);
destructor Done; VIRTUAL;
procedure Store (var S : TStream);
procedure SetState (AState : word; Enable : boolean); VIRTUAL;
procedure ChangeBounds (var Bounds : TRect); VIRTUAL;
procedure ChangeMade;
procedure SetUpField; VIRTUAL;
procedure EvaluateField; VIRTUAL;
procedure SetUpRecord; VIRTUAL;
procedure EvaluateRecord; VIRTUAL;
procedure Draw; VIRTUAL;
procedure DrawField (var Field : pDMXfieldrec);
procedure ZeroizeRecord; VIRTUAL;
procedure ZeroizeField (Whole : boolean; Field : pDMXfieldrec); VIRTUAL;
procedure ProcessMouse (var Event : TEvent);
procedure ProcessCommand (var Command : word; XY : TPoint);
procedure ProcessEnter (var Event : TEvent); VIRTUAL;
procedure ProcessKey (var Event : TEvent);
procedure GotoPos (AFieldNum,ARecNum : integer);
procedure HandleEvent (var Event : TEvent); VIRTUAL;
private
FirstPos : integer;
ShowFmt : showset;
end;
const
RDmxLabels : TStreamRec = (
ObjType: cmDMX + 1;
VmtLink: ofs (TypeOf (TDmxLabels)^);
Load: @TDmxLabels.Load;
Store: @TDmxLabels.Store
);
RDmxScroller : TStreamRec = (
ObjType: cmDMX + 2;
VmtLink: ofs (TypeOf (TDmxScroller)^);
Load: @TDmxScroller.Load;
Store: @TDmxScroller.Store
);
RDmxRecInd : TStreamRec = (
ObjType: cmDMX + 3;
VmtLink: ofs (TypeOf (TDmxRecInd)^);
Load: @TDmxRecInd.Load;
Store: @TDmxRecInd.Store
);
RDmxEditor : TStreamRec = (
ObjType: cmDMX + 4;
VmtLink: ofs (TypeOf (TDmxEditor)^);
Load: @TDmxEditor.Load;
Store: @TDmxEditor.Store
);
procedure RegisterDMX;
implementation
{ ══ TDmxLink ══════════════════════════════════════════════════════════ }
constructor TDmxLink.Init (Bounds : TRect);
begin
TView.Init (Bounds);
GrowMode := gfGrowLoY or gfGrowHiY;
EventMask := evMessage;
end;
constructor TDmxLink.Load (var S : TStream);
begin
TView.Load (S);
GetPeerViewPtr (S, Link);
end;
function TDmxLink.GetPalette : PPalette;
begin
GetPalette := @cDMX
end;
procedure TDmxLink.Store (var S : TStream);
begin
TView.Store (S);
PutPeerViewPtr (S, Link);
end;
procedure TDmxLink.Insert (AOwner : PGroup);
begin
If (AOwner <> nil) then AOwner^.Insert (@Self);
end;
{ ══ TDmxLabels ════════════════════════════════════════════════════════ }
constructor TDmxLabels.Init (DataStr : pstring; var Bounds : TRect);
begin
TDmxLink.Init (Bounds);
Move (DataStr, Data, sizeof (Data));
Len := length (DataStr^);
Inc (PtrRec (Data).Ofs);
GrowMode := gfGrowHiX;
end;
constructor TDmxLabels.InitInsert (AOwner : PGroup; DataStr : pstring);
var R : TRect;
begin
AOwner^.GetExtent (R);
Inc (R.A.Y);
R.B.Y := R.A.Y + 2;
R.Grow (-1, 0);
TDmxLink.Init (R);
Move (DataStr, Data, sizeof (Data));
Len := length (DataStr^);
Inc (PtrRec (Data).Ofs);
GrowMode := gfGrowHiX;
Insert (AOwner);
end;
procedure TDmxLabels.HandleEvent (var Event : TEvent);
var dX,dY : integer;
begin
TDmxLink.HandleEvent (Event);
With Event do
If (What = evBroadcast) and (Command = cmDMX_FixSize) and (Size.X > Len) then
begin
dX := (Owner^.Size.X - Size.X) + Len;
dY := Owner^.Size.Y;
Owner^.GrowTo (dX, dY);
end;
end;
procedure TDmxLabels.Draw;
var A : string;
begin
Move (Data^ [Link^.Delta.X], A [1], Size.X);
If (Link^.Delta.X + Size.X > Len) then
fillchar (A [succ (Len - Link^.Delta.X)], (Size.X + Link^.Delta.X - Len), ' ');
A [0] := chr (lo (Size.X));
WriteStr (0, 0, A, 1);
If (Size.Y > 1) then DrawRuler (TRUE, FALSE);
end;
procedure TDmxLabels.DrawRuler (Upper, AtLimit : boolean);
const
LtArr = 17;
RtArr = 16;
Markers : string [10] = '─═┬╤╥╦┴╧╨╩';
var
Color : word;
i,X,width : integer;
Mk : integer;
frontcut : integer;
fieldrec : pDMXfieldrec;
A : string;
B : TDrawBuffer;
begin
If (longint (Size) = 0) or (Link = nil) or (Link^.DMXfield1 = nil) then Exit;
fieldrec := Link^.LeftField;
If (fieldrec = nil) or (fieldrec^.screentab > Link^.Delta.X) then
fiel